<template>
	<view class="tixiancontainer">
		<view class="header">
			<view class="can">可提现金额 (元)</view>
			<view class="totalprice">￥{{totalprice}}</view>
		</view>
		<view class="tixian_middlie">
			<view class="contentbox ffffff">
				<view class="tijine">提现金额 (元)</view>
				<view class="contentboxbottom">
					<view class="contentleft">
						<view class="danwei">￥</view>
					   <input class="inputmoney" type="number" placeholder="请输入提现金额" v-model="money"></input>
					</view>
					<view class="all" @click="allti">全部提现</view>
				</view>
			</view>
			<!-- <view class="weixin mainpadding ffffff flexbetween" @click="changeIndexWX">
				<view class="weixinicon flexcenter">
					<image class="wximg" src="../../static/images/scenic/weixin-logo.png" mode=""></image>
					<view class="txt flex1">微信</view>
				</view> 
				<view class="right">
					<image v-if="activeIndexWX" src="../../static/images/hotel/checked.png"
						style="width:34rpx;height: 34rpx;"></image>
					<image v-if="!activeIndexWX" src="../../static/images/hotel/unchecked.png"
						style="width: 34rpx;height: 34rpx;"></image>
				</view>
			</view> -->
			<view class="weixin mainpadding ffffff flexbetween" @click="changeIndexJF">
				<view class="weixinicon flexcenter">
					<image class="wximg" src="../../static/images/scenic/zfb.png" mode=""></image>
					<view class="txt flex1">支付宝</view>
				</view> 
				<view class="right">
					<image v-if="!activeIndexJF" src="../../static/images/hotel/unchecked.png"
						style="width:34rpx;height: 34rpx;"></image>
					<image v-if="activeIndexJF" src="../../static/images/hotel/checked.png"
						style="width: 34rpx;height: 34rpx;"></image>
				</view>
			</view>
			<view class="buyBtn" @click.stop="goTixian">提现</view>
			<view class="tixianjilu flexcenter" @click="tixianjilu">提现记录</view>
		</view>
		<u-modal ref="uModal" :show="isshowtoast" :showConfirmButton="false">
				<view class="slot-content flexcenter1">
					 <image class="tixianimg" src="../../static/images/my/tixian.png"></image>
					 <view class="title">提现申请发起成功，正在处理中！</view>
					 <view class="queren" @click="confirm">确认</view>
				</view>
		</u-modal>
	</view>
</template>

<script>
const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
			  totalprice:'',
			  money:'',
			  isshowtoast:false,
			activeIndexJF: false,// 是否使用支付宝
			activeIndexWX: true,// 是否使用微信
			};
		},
		onLoad(options) {
			this.totalprice=options.totalprice
		},
		methods:{
			changeIndexWX() {
				this.activeIndexWX=true
				this.activeIndexJF=false
			},
			changeIndexJF() {
				this.activeIndexJF=true
				this.activeIndexWX=false
			},
			allti(){
				let _this=this
				_this.money=_this.totalprice
			},
			goTixian(){
				let _this=this
				if(_this.money==''){
					uni.hideLoading()
					httpRequest.toast('请输入提取金额!');
					return false;
				}
				if(_this.money<10){
					uni.hideLoading()
					httpRequest.toast('请输入合法金额（不得小于等于10）!');
					return false;
				}
				if(isNaN(_this.money)){
					uni.hideLoading()
					httpRequest.toast('请输入合法金额(数字)!');
					return false;
				}
				if(Number(this.money)>Number(this.totalprice)){
					uni.hideLoading()
					httpRequest.toast('余额不足!');
					return false;
				}
				if (!httpRequest.checkIsLogin()) {
					httpRequest.doLogin();
					return false;
				}
				httpRequest.modal('提示', '确认提现吗？', true, (res) => {
				  if (res) {
					   httpRequest.request('api/user/addWithdrawal', 'POST', {
						   price: _this.money,
						   type:_this.activeIndexWX?1:2
					   }, false, false, true).then(res => {
							if (res.code == 1) {
							  _this.isshowtoast=true
							}
							if(res.code==-1){
								httpRequest.modal('提示',res.msg,true,(res)=>{
									if(res){
										uni.navigateTo({
											url:'/pages/my/zfb'
										})
									}
								})
							}
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
			},
			tixianjilu(){
				uni.navigateTo({
					url:'/pages/my/tixianjilu'
				})
			},
			confirm(){
				let _this=this
				_this.isshowtoast=false
				setTimeout(()=>{
					uni.switchTab({
						url:'/pages/my/my'
					}) 
				},1000)
			}
		}
	}
</script>

<style lang="scss" scoped>
.tixiancontainer{
  min-height: 100vh;
  background-color: #fafafa;
  box-sizing: border-box;
}
.header {
		width: 100%;
		height: 278rpx;
		padding: 30rpx;
		background-size: 100% 100%;
		background-image: url('../../static/images/my/tixianheader.png');
		.can{
		  font-size: 32rpx;
		  font-family: PingFang SC-Heavy, PingFang SC;
		  font-weight: 800;
		  color: #FFFFFF;
		  line-height: 32rpx;
		}
		.totalprice{
			margin-top: 20rpx;
			font-size: 60rpx;
			font-family: PingFang SC-Heavy, PingFang SC;
			font-weight: 800;
			color: #FFFFFF;
			line-height: 60rpx;
		}
	}
.tixian_middlie{
	padding:0 30rpx;
	box-sizing: border-box;
	width: 100%;
	position: relative;
	top:-120rpx;
	.contentbox{
		padding:42rpx 30rpx;
		padding-top: 66rpx;
		padding-bottom: 30rpx;
		border-radius: 20rpx;
	}	
}
.tijine{
	font-size: 28rpx;
	font-family: PingFang SC-Medium, PingFang SC;
	font-weight: 500;
	color: #333333;
	line-height: 33rpx;
}
.contentboxbottom{
	display: flex;
	align-items:center;
	justify-content: space-between;
	margin-top:30rpx;
	border-radius: 20rpx;
	.all{
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #00D2E1;
		line-height: 33rpx;
	}
}
.contentleft{
	display: flex;
	box-sizing: border-box;
	font-size: 40rpx;
	font-family: DIN Next LT Pro-Regular, DIN Next LT Pro;
	font-weight: 400;
	color: #333333;
	line-height: 47rpx;
	.danwei{
		margin-right: 14rpx;
		margin-top: 8rpx;
	}
	.inputmoney::placeholder{
		color: #999999;
	}
}
.weixin{
	margin-top: 30rpx;
	border-radius: 20rpx;
}
.weixinicon{
	.wximg{
		width: 32rpx;
		height: 32rpx;
		margin-right: 8rpx;
	}
	.txt{
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
		line-height: 33rpx;
	}
}

	.buyBtn {
		width: calc(100vw - 60rpx);
		text-align: center;
		padding: 18rpx 0;
		margin-top: 135rpx;
		background-color: #FF5C00;
		color: #fff;
		border-radius: 64rpx;
	}
	.tixianjilu{
		margin-top: 34rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #00D2E1;
		line-height: 38rpx;
	}
 .slot-content{
	 .tixianimg{
		 width: 149rpx;
		 height: 149rpx;
	 }
	 .title{
		 margin-top: 59rpx;
		 font-size: 28rpx;
		 font-family: PingFang SC-Medium, PingFang SC;
		 font-weight: 500;
		 color: #333333;
		 line-height: 33rpx;
	 }
	 .queren{
		 margin-top: 53rpx;
		 border-radius: 41rpx;
		 background-color: rgba(0, 210, 225, 1);
		 text-align: center;
		 padding: 10rpx 129rpx;
		 font-size: 32rpx;
		 font-family: PingFang SC-Medium, PingFang SC;
		 font-weight: 500;
		 color: #FFFFFF;
		 line-height: 38rpx;
		 letter-spacing: 6px;
	 }
 }
</style>
